package com.woniuxy.woniuticket.movieinfomodule.service.impl;

import com.woniuxy.woniuticket.movieinfomodule.dao.CinemaVipDAO;
import com.woniuxy.woniuticket.movieinfomodule.dao.UserVipInfoDAO;
import com.woniuxy.woniuticket.movieinfomodule.service.CinemaVipService;
import com.woniuxy.woniuticket.pojo.CinemaVip;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CinemaVipServiceImp implements CinemaVipService {
    @Resource
    private CinemaVipDAO cinemaVipDAO;
    @Resource
    private UserVipInfoDAO userVipInfoDAO;

    @Override
    public String deleVip(Integer vipId) {
       int num =  userVipInfoDAO.queryUserNum(vipId);
       if(num == 0){
           cinemaVipDAO.deleteByPrimaryKey(vipId);
           return "success";
       }else{
           return "fail";
       }
    }

    @Override
    public List<CinemaVip> showAllVip() {
        return cinemaVipDAO.queryAllVip();
    }

    @Override
    public void updateVip(CinemaVip cinemaVip) {
        cinemaVipDAO.updateByPrimaryKey(cinemaVip);
    }

    @Override
    public void addVip(CinemaVip vip) {
        cinemaVipDAO.insert(vip);
    }


}
